<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <title>JavaScript 数组方法</title>
</head>
<body>
<h2>把数组转换为字符串</h2>
<p>toString() 把数组转换为数组值（逗号分隔）的字符串。</p>

<p id="demo"></p>
<script>
  var fruits=["Banana","Orange","Apple","Mango"];
  document.getElementById("demo").innerHTML=
          fruits.toString();
</script>
</body>
</html>

<!--
输出结果：
Banana,Orange,Apple,Mango

join() 方法也可将所有数组元素结合为一个字符串，还可以规定分隔符：
document.getElementById("demo").innerHTML = fruits.join(" * ");
结果：
Banana * Orange * Apple * Mango
-->